package cn.wetcland.urban.framework.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.framework.dto.CustomerEvaluationDTO;
import cn.wetcland.urban.framework.service.UtEvaluationService;
import cn.wetcland.urban.generator.domain.UtEvaluation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/evaluation")
public class EvaluationController {

    @Resource
    public UtEvaluationService evaluationService;

    @SaCheckLogin
    @PostMapping("/customerEvaluation")
    public AjaxResponse customerEvaluation(@Validated @RequestBody CustomerEvaluationDTO evaluationDTO) {
        evaluationService.handleCustomerEvaluation(evaluationDTO);
        return AjaxResponse.success();
    }

    @GetMapping("/evaluationDetails/{orderId}")
    public AjaxResponse evaluationDetails(@PathVariable Long orderId) {
        UtEvaluation evaluation = evaluationService.evaluationDetails(orderId);
        return AjaxResponse.success(evaluation);
    }

}
